<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 5. Backing up and Restoring Berkeley DB, Java Edition Applications</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Getting Started with Berkeley DB, Java Edition Transaction Processing" />
    <link rel="up" href="index.html" title="Getting Started with Berkeley DB, Java Edition Transaction Processing" />
    <link rel="prev" href="readmodifywrite.html" title="Read/Modify/Write" />
    <link rel="next" href="chkpoint.html" title="Checkpoints" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 5. Backing up and Restoring Berkeley DB, Java Edition Applications</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="readmodifywrite.html">Prev</a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="chkpoint.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="jebackuprestore"></a>Chapter 5. Backing up and Restoring Berkeley DB, Java Edition Applications</h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <p>
          <b>Table of Contents</b>
        </p>
        <dl>
          <dt>
            <span class="sect1">
              <a href="jebackuprestore.html#datamod">Normal Recovery</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="chkpoint.html">Checkpoints</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="backup.html">Performing Backups</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="sect2">
                  <a href="backup.html#partialBackup">Performing a Hot Backup</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="backup.html#completeBackup">Performing an Offline Backup</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="backup.html#dbbackuphelper">Using the DbBackup Helper Class</a>
                </span>
              </dt>
            </dl>
          </dd>
          <dt>
            <span class="sect1">
              <a href="jecatastrophicrecovery.html">Performing Catastrophic Recovery</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="jehotfailover.html">Hot Failover</a>
            </span>
          </dt>
        </dl>
      </div>
      <p>
        Fundamentally, you backup your databases by copying JE log files off to a safe storage location. To restore
        your database from a backup, you copy those files to an appropriate directory on disk and restart your JE
        application.   
    </p>
      <p>
        Beyond these simple activities, there are some differing backup strategies that you may want to consider. These
        topics are described in this chapter.
    </p>
      <p>
        Before continuing, before you review the information on log files and background threads in the 
        <em class="citetitle">Getting Started with Berkeley DB, Java Edition</em> guide. Those topics contain important
        information that is basic to the following discussion on backups and restores.
    </p>
      <div class="sect1" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h2 class="title" style="clear: both"><a id="datamod"></a>Normal Recovery</h2>
            </div>
          </div>
        </div>
        <p>
            Remember that internally JE databases are organized in a BTree, and that in order to operate JE 
            requires the complete BTree be available to it.
        </p>
        <p>
            When database records are created, modified, or deleted, the modifications are represented in the BTree's
            leaf nodes. Beyond leaf node changes, database record modifications can also cause changes to other BTree
            nodes and structures.
        </p>
        <p>    
            Now, if your writes are transaction-protected, then every time a transaction is committed the leaf nodes
            (and <span class="emphasis"><em>only</em></span> the leaf nodes) modified by that transaction are written to the JE log
            files on disk. Also, remember that the durability of the write (whether a flush or fsync is
            performed) depends on the type of commit that is requested.  See <a class="xref" href="nodurabletxn.html" title="Non-Durable Transactions">Non-Durable Transactions</a> for more information.
         </p>
        <p>
            Normal recovery, then, is the process of recreating the entire BTree from the information available in the
            leaf nodes. You do not have to do anything special to cause normal recovery to be run; this occurs every
            time a JE environment is opened.
         </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="readmodifywrite.html">Prev</a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="chkpoint.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Read/Modify/Write </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Checkpoints</td>
        </tr>
      </table>
    </div>
  </body>
</html>
